# -*- coding: utf-8 -*-
# __init__.py create by kumiler
# on 2022/8/28 10:23
# desc


from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from jms.dm.dm_waybill_customer_complaint_version2.complaint_history.daily import \
    jms_dm__dm_waybill_customer_complaint_daily_dt

jms_dm__dm_waybill_customer_complaint_store_agg_new_dt_his = SparkSqlOperator(
    task_id='jms_dm__dm_waybill_customer_complaint_store_agg_new_dt_his',
    email=['shenjiaming@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    name='jms_dm__dm_waybill_customer_complaint_store_agg_new_dt_his_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dm/dm_waybill_customer_complaint_version2/complaint_history/daily_store/execute.sql',
    pool_slots=5,
    executor_cores=2,
    executor_memory='2G',
    driver_memory='5G',
    num_executors=5,
    conf={'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
          'spark.shuffle.service.enabled': 'true',  # 动态资源 Shuffle 服务开启
          'spark.dynamicAllocation.maxExecutors': 6,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.executor.memoryOverhead': '2G',
          'spark.sql.autoBroadcastJoinThreshold': 104857600,  # MapJoin 阈值 100M
          'spark.sql.shuffle.partitions': 300,
          },
    hiveconf={
        'hive.exec.dynamic.partition': 'true',  # 动态分区
        'hive.exec.dynamic.partition.mode': 'nonstrict',
        'hive.exec.max.dynamic.partitions': 600,  # 每天生成 20 个分区
        'hive.exec.max.dynamic.partitions.pernode': 40,  # 每天生成 20 个分区
    },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=30),
)

jms_dm__dm_waybill_customer_complaint_store_agg_new_dt_his << [
    jms_dm__dm_waybill_customer_complaint_daily_dt
]
